package com.hjc.springbootmovies.springconfig;

import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;

import javax.sql.DataSource;

/**
 * Created by IntelliJ IDEA.
 * User: HJC
 * Date: 2019/12/11
 * Time: 15:15
 * To change this template use File | Settings | File Templates.
 */
@SpringBootConfiguration
public class SqlSessionFactoryConfig {
    @Autowired
    private DataSource dataSource;

    public SqlSessionFactoryBean createSqlSessionFactory(){
        SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
        factoryBean.setDataSource(dataSource);
        return factoryBean;
    }

}
